# -*- coding: utf-8 -*-
"""
Created on Sun May 19 14:23:09 2019

@author: Administrator
"""

# 1006 换个格式输出整数
# 用字母B表示百，字母S表示十，用12...n表示不为零的个位数字n(<10)
# 换个格式来输出一个不超过3位正整数
# 例如：234应该输出为BBSSS1234
"""
def test():
    data = str(input())
    if data.isdigit():
        data = int(data)
    else:
        return
    
    if data < 0 or data >= 1000:
        return
    
    str_data = str(data)
    list_data = [int(i) for i in str_data]
    
    result = ""
    length = len(list_data)
    list_data.reverse()
    
    for i in range(length):
        if i == 2:
            result = list_data[i] * "B" + result
        elif i == 1:
            result = list_data[i] * "S" + result
        elif i == 0:
            result = sequence(list_data[i]) + result 
    print(result)


def sequence(number):
    
    result = ""
    if number >= 10 or number <= 0:
        return result
        
    for i in range(number):
        result = result + str(i+1)
        
    return result

#print(sequence(6))
#print(sequence(0))
test()
"""
# 1007 素数对猜想
# 定义d(n) = p(n+1)-p(n)，其中p(i)是第i个素数
# 显然d(1)=1，且对于n>1，有dn是偶数。
# 素数对猜想认为，存在无穷多对相邻且差为2的素数
# 现给定任意正整数N(<10^5)，请计算不超过N的满足猜想的素数对个数

# 运行超时
"""
def test():
    # 获取输入
    data = int(input())
    
    if data <= 0 or data >= 10 ** 5:
        return
    
    # 求出<=该数的所有素数
    prime_list = get_prime_list(data)
    
    
    prime_pair_list = []
    # 计算相邻的素数对
    for index in range(len(prime_list)-1):
        temp = []
        temp.append(prime_list[index])
        temp.append(prime_list[index+1])
        prime_pair_list.append(temp)
    # 如果素数对差为2，计数+1
    count = 0
    for index in range(len(prime_pair_list)):
        if diff_prime_pair(prime_pair_list[index]) == 2:
            count = count + 1
    
    print(count)

# 判断素数1
#import math
def prime(data):
    for i in range(2,data):
        if data % i == 0:
            return False
    return True

#print(prime(9))

def get_prime_list(data):
    prime_list = []
    for i in range(2, data+1):
        if prime(i) == True:
            prime_list.append(i)
    return prime_list

#print(get_prime_list(20))
    
def diff_prime_pair(prime_pair):
    return prime_pair[1] - prime_pair[0]

#diff_prime_pair([2,3])
"""

"""
import math

def test2():
    # 获取输入
    data = int(input())
    
    if data <= 0 or data >= 10 ** 5:
        return
    
    # 求出<=该数的所有素数
    prime_list = get_prime_list(data)
    
    count = 0
    for i in range(len(prime_list)-1):
        if (prime_list[i+1] - prime_list[i]) == 2:
            count = count + 1
    
    print(count)

#判断素数2
#import math
#def prime(data):
#    sqrt_data = math.ceil(math.sqrt(data))
#    for i in range(2,sqrt_data+1):
#        if data % i == 0:
#            return False
#    return True

#print(prime(9))
#import math

#判断素数3
def prime(data):
    if data == 1:
        return False
    if data == 2 or data == 3:
        return True
    if data % 6 != 1 and data % 6 != 5:
        return False
    sqrt_data = math.ceil(math.sqrt(data))
    for i in range(5, sqrt_data+1, 6):
        if data % i == 0 or data % (i+2) == 0:
            return False
    return True

def get_prime_list(data):
    prime_list = []
    for i in range(2, data+1):
        if prime(i) == True:
            prime_list.append(i)
    return prime_list

test2()
"""

# 1008 数组循环右移问题
# 数组A中存有N(>0)个整数，在不允许使用另外数组的前提下，将每个整数循环
# 向右移M(>=0)个位置，即将（A0A1..An-1）变为（An-m，...An-1A0A1... An-m-1）
# 如果需要考虑程序移动数据的次数尽量少，要如何设计？

"""
def test():
    # 获取输入
    meta = str(input()).split(' ')
    shift = int(meta[1])
    data = str(input()).split(' ')
    # 根据右移次数循环取出列尾，插入列头
    for i in range(shift):
        last_element = data.pop()
        data.insert(0, last_element)
    
    result = " ".join(data)
    print(result)

test()
"""

# 1009 说反话
# 给定一句英语，要求编写程序，将句中所有单词的顺序颠倒输出
# 输入：
# Hello World Here I Come
# Come I Here World Hello
"""
def test():
    raw = input()
    if len(raw) > 80:
        return
    
    words_list = str(raw).split(' ')
    
    words_list.reverse()
    
    print(" ".join(words_list))
    
test()
"""
# 1010 一元多项式求导
# 设计函数求一元多项式的导数
# x^n的一阶导数为n*x^(n-1) n为整数

# bug
def test():
    data_list = str(input()).split(' ')
    
    data_list = [int(i) for i in data_list]
    
    result = []
    for i in range(0,len(data_list)-1,2):
        if (data_list[i] == 0 or data_list[i+1] == 0):
            continue

        coef = data_list[i] * data_list[i+1]
        result.append(coef)
        
        index = data_list[i+1] - 1
        result.append(index)
    
    if not result:
        print('0 0')
    else:
        result = [str(i) for i in result]
        print(" ".join(result))
    
test()

